package com.xgp.order.feign.fallback;
import java.math.BigDecimal;

import com.xgp.order.feign.ProductFeignClient;
import com.xgp.product.bean.Product;
import org.springframework.stereotype.Component;

//兜底回调，远程调用发送错误时，返回默认数据
@Component
public class ProductFeignClientFallback implements ProductFeignClient {

//    实现兜底回调的数据
    @Override
    public Product getProductById(Long id) {
        System.out.println("触发兜底回调！。。。。");
        Product product = new Product();
        product.setId(id);
        product.setPrice(new BigDecimal("0"));
        product.setProductName("未知商品");
        product.setNum(0);

        return product;
    }
}
